#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	char s[110];
	while(scanf("%s",s)!=EOF)
	{
		int flag = 0;
		int len = strlen(s);
		for(int i = 0;i<len;i++)
		{
			if(s[i]=='H'||s[i]=='Q'||s[i]=='9')
			{
				flag = 1;
				break;
			}
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
} 
